import React from 'react'
import { connect } from 'dva'
import { mapStateToProps } from 'utils/view_utils'
import styles from './forSaleEditStyle.less'
import { CollapsiblePanels } from 'widget/CollapsiblePanels/index'
import PopUpSelect from 'widget/PopUpSelectnoModal/PopUpSelect'
import { isEmpty, cloneDeep, } from 'lodash'
import cx from 'classnames'
import locale from 'antd/lib/date-picker/locale/zh_CN';
import { Form, Input, Select, Row, Col, Button, DatePicker, Radio  } from 'antd';
// import { message,DatePicker} from 'antd';
import moment from 'moment';
import 'moment/locale/zh-cn';
moment.locale('zh-cn');
const FormItem = Form.Item;
const { RangePicker } = DatePicker;
const { Option } = Select
const routeView = function ({ dispatch, model, form }) {
    const { modelObj, namespace } = model
    const { getFieldDecorator } = form
    let { areaList, query, detail, addressList } = modelObj
    //console.log('selectItem',selectItem)
    // PopUpSelect 需要row配置
    const formItemLayout = {
        labelCol: {
            span: 1,

        },
        wrapperCol: {
            span: 16
        },
    }

    function updateModel(value, key, obj){
        detail[key] = value
        dispatch({
            type: `${namespace}/updateStore`,
            payload: { detail }
        })
    }
    //选择角色

    //date改变时
    return (
        <div className={cx('public_listMain')}>
            <div className="functionButton">
                <Button type='primary' loading={modelObj.btnLoading} onClick={() => {
                    form.validateFields((err) => {
                        if(!err){
                            dispatch({
                                type: `${namespace}/update`,
                                payload: {detail}
                            })
                        }
                    });

                }} >保存</Button>
            </div>
            <CollapsiblePanels title="二手房信息" hideUpDownBtn={true}  >
                <Form autoComplete="off" className="auto-wrap" >

                    <Row style={{ borderBottom: "1px solid #EFF0F2" }}>
                        <Col span={8}>
                            <FormItem {...formItemLayout} label="小区名称" labelCol={{ span: 5 }}>
                                <div>
                                    {getFieldDecorator('name', {
                                        initialValue: detail.name,
                                        rules: [
                                            { required: true, whitespace: true, message: '请输入小区名称' },
                                        ],
                                        })(<Input
                                        placeholder={'请输入小区名称'}
                                        autoComplete={'off'}
                                        
                                        maxLength={50}
                                        onChange={(e) => { updateModel(e.target.value, 'name', 'detail') }}
                                    />)}
                                </div>
                            </FormItem>
                        </Col>
                        <Col span={8}>
                            <FormItem {...formItemLayout} label="小区地址" labelCol={{ span: 5 }}>
                                <div>
                                    {getFieldDecorator('address', {
                                        initialValue: detail.address,
                                        rules: [
                                            { required: true, whitespace: true, message: '请输入小区地址' },
                                        ],
                                        })(<Input
                                        placeholder={'请输入小区地址'}
                                        autoComplete={'off'}
                                        maxLength={100}
                                        onChange={(e) => { updateModel(e.target.value, 'address', 'detail') }}
                                    />)}
                                </div>
                            </FormItem>
                        </Col>
                        <Col span={8}>
                            <FormItem {...formItemLayout} label="户型" labelCol={{ span: 5 }} >
                                <div className={cx('select-item-contain')}>
                                    {getFieldDecorator('houseHold', {
                                        initialValue: detail.houseType,
                                        rules: [
                                            { required: true, whitespace: true, message: '请输入户型' },
                                        ],
                                        })(<Input
                                        placeholder={'请输入户型'}
                                        autoComplete={'off'}
                                        onChange={(e) => { updateModel(e.target.value, 'houseType', 'detail') }}
                                    />)}
                                </div>
                            </FormItem>
                        </Col>
                    </Row>
                    <Row style={{ borderBottom: "1px solid #EFF0F2" }}>

                        <Col span={8}>
                            <FormItem {...formItemLayout} label="建筑面积" labelCol={{ span: 5 }} >
                                <div className={cx('select-item-contain')}>
                                    {getFieldDecorator('area', {
                                        initialValue: detail.area,
                                        rules: [
                                            { required: true, whitespace: true, message: '请输入建筑面积' },
                                        ],
                                        })(<Input
                                        placeholder={'请输入建筑面积'}
                                        autoComplete={'off'}
                                        type="number"
                                        onChange={(e) => { updateModel(e.target.value, 'area', 'detail') }}
                                    />)}
                                </div>
                            </FormItem>
                        </Col>
                        <Col span={8}>
                            <FormItem {...formItemLayout} label="楼层" labelCol={{ span: 5 }}>
                                <div className={cx('select-item-contain')}>
                                    {getFieldDecorator('floor', {
                                        initialValue: detail.floor,
                                        rules: [
                                            { required: true, whitespace: true, message: '请输入楼层' },
                                        ],
                                        })(<Input
                                        placeholder={'请输入楼层'}
                                        autoComplete={'off'}
                                        type="number"
                                        onChange={(e) => { updateModel(e.target.value, 'floor', 'detail') }}
                                    />)}
                                </div>
                            </FormItem>
                        </Col>

                    </Row>
                    <Row style={{ borderBottom: "1px solid #EFF0F2" }}>

                        <Col span={8}>
                            <FormItem {...formItemLayout} label="朝向" labelCol={{ span: 5 }} >
                                <div className={cx('select-item-contain')}>
                                    {getFieldDecorator('direction', {
                                        initialValue: detail.direction,
                                        rules: [
                                            { required: true, whitespace: true, message: '请选择朝向' },
                                        ],
                                        })(<Radio.Group  value={detail.direction}>
                                            <Radio value={0}>东</Radio>
                                            <Radio value={1}>南</Radio>
                                            <Radio value={2}>西</Radio>
                                            <Radio value={4}>北</Radio>
                                          </Radio.Group>)}
                                </div>
                            </FormItem>
                        </Col>
                        <Col span={8}>
                            <FormItem {...formItemLayout} label="装修情况" labelCol={{ span: 5 }}>
                                <div className={cx('select-item-contain')}>
                                    {getFieldDecorator('floor', {
                                        initialValue: detail.floor,
                                        rules: [
                                            { required: true, whitespace: true, message: '请选择装修情况' },
                                        ],
                                        })(<Radio.Group value={detail.floor}>
                                            <Radio value={0}>毛坯</Radio>
                                            <Radio value={1}>简装</Radio>
                                            <Radio value={2}>精装</Radio>
                                          </Radio.Group>)}
                                </div>
                            </FormItem>
                        </Col>

                    </Row>
                    <Row style={{ borderBottom: "1px solid #EFF0F2" }}>

                        <Col span={8}>
                            <FormItem {...formItemLayout} label="电梯" labelCol={{ span: 5 }}>
                                <div className={cx('select-item-contain')}>
                                    {getFieldDecorator('elevator', {
                                        initialValue: detail.floor,
                                        rules: [
                                            { required: true, whitespace: true, message: '请选择装修情况' },
                                        ],
                                        })(<Radio.Group  value={detail.floor}>
                                            <Radio value={0}>无</Radio>
                                            <Radio value={1}>有</Radio>
                                            </Radio.Group>)}
                                </div>
                            </FormItem>
                        </Col>
                        <Col span={8}>
                            <FormItem {...formItemLayout} label="房屋类型" labelCol={{ span: 5 }}>
                                    <div className={cx('select-item-contain')}>
                                        {getFieldDecorator('propertyType', {
                                            initialValue: detail.propertyType,
                                            rules: [
                                                { required: true, whitespace: true, message: '请选择房屋类型' },
                                            ],
                                            })(<Radio.Group value={detail.propertyType}>
                                                <Radio value={0}>普通住宅</Radio>
                                                <Radio value={1}>公寓</Radio>
                                                <Radio value={2}>别墅</Radio>
                                                <Radio value={3}>平房</Radio>
                                                <Radio value={4}>商住房</Radio>
                                                <Radio value={5}>去哦他</Radio>
                                                </Radio.Group>)}
                                    </div>
                            </FormItem>
                        </Col>

                    </Row>
                    <Row style={{ borderBottom: "1px solid #EFF0F2" }}>

                        <Col span={8}>
                            <FormItem {...formItemLayout} label="期望售价" labelCol={{ span: 5 }} >
                                <div className={cx('select-item-contain')}>
                                    {getFieldDecorator('pirce', {
                                        initialValue: detail.price,
                                        rules: [
                                            { required: true, whitespace: true, message: '请输入售价' },
                                        ],
                                        })(<Input
                                        placeholder={'请输入售价'}
                                        autoComplete={'off'}
                                        type="number"
                                        onChange={(e) => { updateModel(e.target.value, 'price', 'detail') }}
                                    />)}
                                </div>
                            </FormItem>
                        </Col>
                        <Col span={8}>
                            <FormItem {...formItemLayout} label="房屋介绍" labelCol={{ span: 5 }}>
                                <div className={cx('select-item-contain')}>
                                    {getFieldDecorator('description', {
                                        initialValue: detail.description,
                                        rules: [
                                            { required: true, whitespace: true, message: '请输入房屋介绍' },
                                        ],
                                        })(<Input.TextArea
                                        placeholder={'请输入房屋介绍'}
                                        autoComplete={'off'}
                                        onChange={(e) => { updateModel(e.target.value, 'description', 'detail') }}
                                    />)}
                                </div>
                            </FormItem>
                        </Col>

                    </Row>
                    <Row style={{ borderBottom: "1px solid #EFF0F2" }}>

                        <Col span={8}>
                            <FormItem {...formItemLayout} label="联系人" labelCol={{ span: 5 }} >
                                <div className={cx('select-item-contain')}>
                                    {getFieldDecorator('contact', {
                                        initialValue: detail.contact,
                                        rules: [
                                            { required: true, whitespace: true, message: '请输联系人' },
                                        ],
                                        })(<Input
                                        placeholder={'请输入联系人'}
                                        autoComplete={'off'}
                                        onChange={(e) => { updateModel(e.target.value, 'contact', 'detail') }}
                                    />)}
                                </div>
                            </FormItem>
                        </Col>
                        <Col span={8}>
                            <FormItem {...formItemLayout} label="联系方式" labelCol={{ span: 5 }}>
                                <div className={cx('select-item-contain')}>
                                    {getFieldDecorator('mobile', {
                                        initialValue: detail.mobile,
                                        rules: [
                                            { required: true, whitespace: true, message: '请输入联系方式' },
                                        ],
                                        })(<Input
                                        placeholder={'请输入联系方式'}
                                        autoComplete={'off'}
                                        type="number"
                                        onChange={(e) => { updateModel(e.target.value, 'mobile', 'detail') }}
                                    />)}
                                </div>
                            </FormItem>
                        </Col>

                    </Row>
                    <Row style={{ borderBottom: "1px solid #EFF0F2" }}>

                        <Col span={8}>
                            <FormItem {...formItemLayout} label="室内图片" labelCol={{ span: 5 }} >
                                <div className={cx('select-item-contain')}>
                                    
                                </div>
                            </FormItem>
                        </Col>
                        <Col span={8}>
                            <FormItem {...formItemLayout} label="审核意见" labelCol={{ span: 5 }}>
                                <div className={cx('select-item-contain')}>
                                    {getFieldDecorator('remark', {
                                        initialValue: detail.remark,
                                        rules: [
                                            { required: true, whitespace: true, message: '请输入审核意见' },
                                        ],
                                        })(<Input.TextArea
                                        placeholder={'请输入审核意见'}
                                        autoComplete={'off'}
                                        onChange={(e) => { updateModel(e.target.value, 'remark', 'detail') }}
                                    />)}
                                </div>
                            </FormItem>
                        </Col>

                    </Row>
                </Form>
            </CollapsiblePanels>
        </div>

    )


}
export default connect(mapStateToProps)(Form.create()(routeView))

